package twosigma;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.regex.Pattern;
/*
 * SortString.java
 * Usage: Two Sigma Code Test. Sort a list of Strings (Integers or words)
 * Author: Guannan Zhang
 * Date 3/8/2012
 */
public class SortString {

	public SortString() {

	}

	public static void main(String[] args) {

		SortString t = new SortString();
		t.sort();

	}

	public void sort() {

		try {
			//list to store integers
			ArrayList<Integer> n = new ArrayList<Integer>();
			//list to store words
			ArrayList<String> w = new ArrayList<String>();

			//read a line from std in
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String line = br.readLine();

			String[] str = line.split(" ");

			Pattern p = Pattern.compile("-*\\d+");
			for (String s : str) {
				//use regular expressions to determine integers
				if (p.matcher(s).matches()) {
					n.add(Integer.parseInt(s));
				} else {
					w.add(s);
				}
			}
			//sort integers
			Collections.sort(n);
			//sort words
			Collections.sort(w);

			int i = 0;
			int j = 0;

			//construct the output array
			for (int k = 0; k < str.length; k++) {
				if (p.matcher(str[k]).matches()) {
					str[k] = String.valueOf(n.get(i++));
				} else {
					str[k] = w.get(j++);
				}
			}
			
			//std out
			for (int k = 0; k < str.length - 1; k++) {
				System.out.print(str[k] + " ");
			}
			System.out.println(str[str.length - 1]);
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}
